<!--
 * @Description: 
 * @Author: shizhe
 * @Date: 2022-03-30 13:21:46
 * @LastEditTime: 2022-04-19 11:10:34
 * @LastEditors: shizhe
 * @Reference: 
-->
<template>
  <div id="com_square">
    <h1>交易信息</h1>
    <div class="nocontent_bg" v-show="!total">
      <el-image :src="require('@/assets/role_bg2.png')"></el-image>
      <p style="color: #999999">暂无交易信息</p>
    </div>
    <div style="margin-top: 20px" class="table_box" v-show="total">
      <el-table
        :data="tableData"
        class="table"
        height="100%"
        tooltip-effect="light"
        ref="jdjgTable"
        border
        :header-cell-style="{
          padding: '0px',
          background: 'linear-gradient(0deg, #F4F6F9, #EAECF4, #F3F6F9)'
        }"
        :row-class-name="tabRowClassName"
        header-row-class-name="mapTable_th"
      >
        <el-table-column width="60" align="center" type="index" label="序号">
          <template slot-scope="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column label="招标内容" align="center" width="180" prop="materialInfo" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="工程名称" align="center" width="180" prop="proName" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="采购商" align="center" width="180" prop="biddingEnterprise" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="中标时间" align="center" width="180" prop="winTime" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="签约时间" align="center" width="180" prop="takeEffectDate" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="状态" align="center" prop="dealStatus">
          <template slot-scope="scope">
            {{ scope.row.dealStatus == 1 ? '中标' : '签约' }}
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div style="margin-top: 40px" v-show="total">
      <element-pagination
        :Total="total"
        @getData="getPagChange"
        :Layout="'total,  prev, pager, next, jumper'"
        :Size="15"
      ></element-pagination>
    </div>
  </div>
</template>

<script>
import ElementPagination from '../../../components/ElementPagination.vue'
export default {
  components: { ElementPagination },
  props: {
    id: {
      type: [String, Number]
    }
  },
  data() {
    return {
      tableData: [],
      total: 0,
      page: 1,
      size: 15
    }
  },
  mounted() {
    this.getData()
  },
  watch: {
    id() {
      this.getData()
    }
  },
  methods: {
    getData() {
      this.$https({
        method: 'post',
        url: '/enterpriseInfo/getDealInfo',
        data: {
          page: this.page,
          size: this.size,
          enterpriseId: this.id
        }
      })
        .then(res => {
          if (res.code == 0) {
            this.tableData = [...res.data.records] || []
            this.total = res.data.total || 0
          } else {
            this.$message.error(res.msg)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    tabRowClassName({ row, rowIndex }) {
      let index = rowIndex + 1
      if (index % 2 == 0) {
        return 'warning-row'
      }
    },
    getPagChange(data) {
      this.page = data.currentPage
      this.size = data.pagesize
      this.getData()
    }
  }
}
</script>
<style lang="less" scoped>
#com_square {
  padding: 20px;
  border: 1px solid #d6d6d6;
  border-top: none;
  max-height: 657px;
  .table_box {
    height: calc(100% - 112px);
  }
  h1 {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    padding-left: 10px;
    border-left: 4px solid #fa7355;
    span {
      font-weight: normal;
      color: #999;
    }
  }
  .nocontent_bg {
    height: 228px;
  }
}
</style>
